package 工厂模式;

import 工厂模式.impl.Chinese;
import 工厂模式.impl.English;
import 工厂模式.impl.Math;
import 工厂模式.impl.Physics;

public class BookFactory {
    public static final int TYPE_CHINESE = 1;
    public static final int TYPE_MATH = 2;
    public static final int TYPE_ENGLISH = 3;
    public static final int TYPE_PHYSICS = 4;

    public static Book information (int type){
        switch (type){
            case TYPE_CHINESE:
                return new Chinese();
            case TYPE_MATH:
                return new Math();
            case TYPE_ENGLISH:
                return new English();
            case TYPE_PHYSICS:
                return new Physics();
            default:
                throw new RuntimeException("无此类型："+type);
        }
    }
    private BookFactory(){}
}
